<template>
	<view>
		<view style="height: 30rpx;"></view>
		<view style="width: 95%;margin: auto;border-radius: 20rpx;background-color: #FFF;">
			<view style="height: 2rpx;"></view>
			<view class="plr-36 mt-30">
				<view class="gray-1">
					当前位置
				</view>
				<view class="size-40 bold mt-10">
					{{address}}
				</view>
			</view>
			<view class="plr-36 mt-60 gray-1">
				紧急联系人
			</view>
			<view @click="compile(i)" style="width: 95%;margin: auto;height: 80rpx;line-height: 80rpx;background-color: #f7f7f7;border-radius: 10rpx;margin-top: 20rpx;" class="plr-36 mt-30" v-for="i in list">
				<text>{{i.name}}: {{i.mobile}}</text>
			</view>
			<view class="plr-36 mt-60" style="color: #FFAE00;font-size: 28rpx;" @click="goAdd">点击新增紧急联系人</view>
			<view style="height: 50rpx;"></view>
		</view>
		<!-- <u-cell-item icon="man-add" title="点击新增紧急联系人" @click="goAdd" v-if="userInfo.emergency_contact==''"></u-cell-item>
		<u-cell-item icon="man-add" :title="userInfo.emergency_contact" :arrow="false" v-if="userInfo.emergency_contact!=''"></u-cell-item>
		<u-cell-item icon="phone" :title="userInfo.contact_tel" :arrow="false" v-if="userInfo.contact_tel!=''"></u-cell-item> -->
		<view class="fixed-bottom plr-36 pb-50">
			<view class="size-32 red">
				遇到危险，请立即向警方求助
			</view>
			<view class="mtb-20">
				谎报警将可能被处以五日以上十日以下拘留
			</view>
			<u-button type="primary" @click="submit">呼叫110</u-button>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'
	import amapFile from '../../libs/amap-wx.js'
	export default {
		data() {
			return {
				address: '',
				name: '',
				tel: '',
				key: 'bb6f4ed802756f963b37c184ce4e9766',
				list:[]
			}
		},
		computed: {
			...mapState(['userInfo'])
		},
		onShow() {
			this.contactsList()
			var _this = this;
			this.amapPlugin = new amapFile.AMapWX({
				key: this.key
			});
			// this.getRegeo()
			// uni.getLocation({
			// 	type: 'gcj02',
			// 	geocode: true,
			// 	success: function(res) {
			// 		console.log(res);
			// 		_this.address = res.address.province + res.address.city + res.address.district + res.address.street + res.address
			// 			.poiName
			// 	}
			// });
		},
		methods: {
			contactsList(){
				this.$http('user/clossuserList',{},"POST").then(data=>{
					console.log(data);
					this.list = data
				})
			},
			goAdd() {
				uni.navigateTo({
					url: '/pages/home/person-add'
				})
			},
			//编辑
			compile(item){
				uni.navigateTo({
					url: '/pages/home/person-add?item=' + item.id
				})
			},
			//获取位置
			getRegeo() {
				let _this = this
				uni.showLoading({
					title: '获取定位信息中'
				});
				this.amapPlugin.getRegeo({
					success: (data) => {
						this.address = data[0].name
						uni.hideLoading();
					}
				});
			},
			submit() {
				uni.makePhoneCall({
					phoneNumber: '110' //仅为示例
				});
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #F6F7FB;
	}
	/deep/.u-btn {
		height: 96rpx !important;
	}

	/deep/.u-primary-hover {
		background-color: $blue !important;
	}
</style>
